// pages/authentication/components/DefineInput/index.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    placeholder: { type: String, value: '请输入' },
    type: { type: String, value: 'text' },
    text: { type: Boolean, value: false },
    errorMsg: { type: String, observer(newValue) {
      this.setData({ errorMsg: newValue });
    } },
    label: { type: String, value: '' },
    value: {
      type: String | Array | Object,
      observer(newval, oldval) { //  监听数据的变化
        if(newval.length > 0) this.setData({ errorMsg: '' });
        if (newval !== oldval) this.setData({ value: newval });
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    onInput(event) {
      const { value } = event.detail;
      this.triggerEvent('input', value.trim());
    },
    onHideErrorMsg() {
      this.setData({ errorMsg: '' });
    }
  }
})